<?php
/**
 * 21cnjySDK
 * @author    Simon <150986416@qq.com>
 * @filename  Common.php
 * @created   2017/7/5 上午11:59
 */

namespace sdk\modules;

/**
 * 公共资源接口
 * Class Common
 * @see http://dev.21cnjy.com/docs/#api-Common
 * @package sdk\modules
 */
class Common extends Module
{
    /**
     * 获取一个学段下的科目信息
     * @see http://dev.21cnjy.com/docs/#api-Common-Subjects
     * @param int $stage 学段ID, 1:小学，2:初中，3:高中
     * @return bool|mixed
     */
    public function getSubjects($stage)
    {
        return $this->client->httpGet('/api/v3/common/subjects', array(
            'stage' => $stage
        ));
    }

    /**
     * 获取一个学段学科下的教材版本信息
     * @see http://dev.21cnjy.com/docs/#api-Common-Versions
     * @param int $stage 学段ID, 1:小学，2:初中，3:高中
     * @param int $subjectId 科目ID.
     * @return bool|mixed
     */
    public function getVersions($stage, $subjectId)
    {
        return $this->client->httpGet('/api/v3/common/versions', array(
            'stage' => $stage,
            'subjectId' => $subjectId
        ));
    }

    /**
     * 获取一个版本下的教材册别信息
     * @see http://dev.21cnjy.com/docs/#api-common-books
     * @param int $versionId 版本ID
     * @param int $page 分页页码
     * @param int $pageSize 每页显示条数
     * @return bool|mixed
     */
    public function getBooks($versionId)
    {
        return $this->client->httpGet('/api/v3/common/books', array(
            'versionId' => $versionId
        ));
    }

    /**
     * 获取教材章节信息
     * @see http://dev.21cnjy.com/docs/#api-common-chapters
     * @param int $bookId 教材册别信息
     * @return bool|mixed
     */
    public function getChapters($bookId)
    {
        return $this->client->httpGet('/api/v3/common/chapters', array(
            'bookId' => $bookId,
        ));
    }

    /**
     * 获取指定学段科目下的知识点信息
     * @see http://dev.21cnjy.com/docs/#api-common-knowledge
     * @param int $stage 学段ID
     * @param int $subjectId 学科ID
     * @return bool|mixed
     */
    public function getKnowledge($stage, $subjectId)
    {
        return $this->client->httpGet('/api/v3/common/knowledge', array(
            'stage' => $stage,
            'subjectId' => $subjectId,
        ));
    }

    /**
     * 获取所有省级地区数据
     * @see http://dev.21cnjy.com/docs/#api-common-provinces
     * @return bool|mixed
     */
    public function getProvinces()
    {
        return $this->client->httpGet('/api/v3/common/provinces', array());
    }
}